package com.web.music.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;

@Entity
@DiscriminatorValue("BAND")
public class MusicBand extends Artist {

	private String title;

	private String bandAttribute;

	@ManyToMany
	private List<Person> members = new ArrayList<Person>();

	public String getTitle(){
		return title;
	}

	public MusicBand() {
		super();
	}

	public MusicBand(Long Id, String bandAttribute, String title) {
		super(Id);
		this.bandAttribute = bandAttribute;
		this.title = title;
	}

	public String getBandAttribute(){
		return bandAttribute;
	}

	public void setBandAttribute(String bandAttribute ){
		this.bandAttribute = bandAttribute;
	}

	public void setTitle(String title ){
		this.title = title;
	}

	public List<Person> getMembers() {
		return members;
	}

	public void setMembers(List<Person> members) {
		this.members = members;
	}

	@Override
	public boolean equals(Object obj) {
		boolean result = true;
		if (obj instanceof MusicBand) {
			result = this.title.equals(((MusicBand) obj).getTitle())
						&& this.bandAttribute.equals(((MusicBand) obj).getBandAttribute())
						&& this.getId().equals(((MusicBand) obj).getId());
			return result;
		}
		return false;
	}

	@Override
	public String toString() {
		return this.title + " " + this.bandAttribute + " " + getId();
	}
	
	@Override
	public int hashCode() {
		return toString().hashCode();
	}

}
